package com.leave.service;

import com.leave.dao.DepartmentDao;
import com.leave.entity.Department;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

public class DepartmentService {
    private DepartmentDao departmentDao;
    public List<Department> departmentList(Department department){
        List<Department> list =null;
        list =departmentDao.query(department);
        return list;
    }
    public void deleteDep(String depID){
        departmentDao.delete(depID);
    }

//    public List<Department> seek(String depID) {
//        Department department=new Department();
//        department.setDepID(depID);
//        List<Department> list =departmentDao.query(department);
//        return list;
//
//    }

    /**
     *
     *模糊查找
     */
    public List<Map<String, Object>> seek(String keyword) throws SQLException {
        if(keyword != null){
            return departmentDao.selectList(keyword);
        }else{
            return null;
        }
    }

    public boolean addDep(Department department){
        departmentDao.insert(department);
        return true;
    }
    public boolean editDep(Department department){
        departmentDao.update(department);
        return true;
    }
    public void setDepartmentDao(DepartmentDao departmentDao) {
        this.departmentDao=departmentDao;
    }
}
